package com.collage.util;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Result implements Serializable {

    private String code = "000";

    private String message = "成功";

    private Long total;

    private Object data;

    public Result() {}

    public Result(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(String code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public Result(Object data) {
        this.data = data;
    }

    public Result(Object data, long total) {
        this.data = data;
        this.total = total;
    }

    public static Result success() {
        return new Result();
    }

    public static Result success(Object data) {
        return new Result(data);
    }

    public static Result success(Object data, long total) {
        return new Result(data, total);
    }

    public static Result failed(String code, String message) {
        return new Result(code, message);
    }

    public static Result failed(String message) {
        return new Result("500", message);
    }
}
